window.STRING_TYPE = '[object String]';
window.NUMBER_TYPE = '[object Number]';
window.BOOLEAN_TYPE = '[object Boolean]';
window.NULL_TYPE = '[object Null]';
window.UNDEFINED_TYPE = '[object Undefined]';
window.SYMBOL_TYPE = '[object Symbol]';
window.OBJECT_TYPE = '[object Object]';
window.ARRAY_TYPE = '[object Array]';
window.FUNCTION_TYPE = '[object Function]';

/**
 * 获取数据类型(Object.prototype.toString)
 * @param {String || Number || Boolean || Null || Undefined || Symbol || Object || Array || Function} any
 * @returns {String} the any type
 */
window.getType = function (any) {
  return Object.prototype.toString.call(any);
}

/**
 * is String
 * @param {any}
 * @returns {Boolean}
 */
window.isString = function (any) {
  return window.getType(any) === window.STRING_TYPE;
}

/**
 * is Number
 * @param {any} any
 * @returns {Boolean}
 */
window.isNumber = function (any) {
  return window.getType(any) === window.NUMBER_TYPE;
}

/**
 * is Boolean
 * @param {any} any
 * @returns {Boolean}
 */
window.isBoolean = function (any) {
  return window.getType(any) === window.BOOLEAN_TYPE;
}

/**
 * is Null
 * @param {any} any
 * @returns {Boolean}
 */
window.isNull = function (any) {
  return window.getType(any) === window.NULL_TYPE;
}

/**
 * is Undefined
 * @param {any} any
 * @returns {Boolean}
 */
window.isUndefined = function (any) {
  return window.getType(any) === window.UNDEFINED_TYPE;
}

/**
 * is Symbol
 * @param {any} any
 * @returns {Boolean}
 */
window.isSymbol = function (any) {
  return window.getType(any) === window.SYMBOL_TYPE;
}

/**
 * is Object
 * @param {any} any
 * @returns {Boolean}
 */
window.isObject = function (any) {
  return window.getType(any) === window.OBJECT_TYPE;
}

/**
 * is Array
 * @param {any} any
 * @returns {Boolean}
 */
window.isArray = function (any) {
  return window.getType(any) === window.ARRAY_TYPE;
}

/**
 * is Function
 * @param {any} any
 * @returns {Boolean}
 */
window.isFunction = function (any) {
  return window.getType(any) === window.FUNCTION_TYPE;
}

/**
 * 对Date的扩展，将 Date 转化为指定格式的String
 * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符
 * 毫秒(S)可以用 1-3 个占位符
 * 年(Y)可以用 1-4 个占位符
 * @param {String} fmt
 * @returns String
 */
window.Date.prototype.Format = function (fmt) {
  var o = {
    'M+': this.getMonth() + 1, // 月份
    'D+': this.getDate(), // 日
    'h+': this.getHours(), // 小时
    'm+': this.getMinutes(), // 分
    's+': this.getSeconds(), // 秒
    'q+': Math.floor((this.getMonth() + 3) / 3) // 季度
  };
  if (/(Y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
  }
  for (var k in o) {
    if (new RegExp('(' + k + ')').test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
    }
  }
  if (/(S+)/.test(fmt)) {
    var S = this.getMilliseconds();
    if (S < 10) {
      S = '00' + S;
    } else if (S < 100) {
      S = '0' + S;
    }
    console.log(S);
    fmt = fmt.replace(RegExp.$1, (this.getMilliseconds() + '').substr(0, RegExp.$1.length));
  }
  return fmt || this;
}
